package 并发编程09.安全发布类型4;

/**
 * @author idea
 * @data 2019/1/24
 */
public class SingletonDemo4 {

    private volatile static SingletonDemo4 instance = null;

    /**
     * 获取单例数据
     *
     * @return
     */
    public static SingletonDemo4 getInstance() {
        if (instance == null) {
            synchronized (SingletonDemo4.class) {
                if (instance == null) {
                    instance = new SingletonDemo4();
                    return instance;
                }
            }
        }
        return instance;
    }

}
